﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PrimaryAlgorithm.ContainsDuplicate
{
    class MainProject
    {
        static void Main(string[] args)
        {
            int[] nums = new int[] { 7, 1, 5, 3, 6, 4,4 };
            Console.WriteLine(ContainsDuplicate(nums));
            Console.ReadKey();
        }
        public static bool ContainsDuplicate(int[] nums)
        {
            //先排序才求解
            //不重复集合
            HashSet<int> ts = new HashSet<int>();
            foreach (var item in nums)
            {
                if (!ts.Add(item))
                {
                    return true;
                }
            }
            return false;
        }
    }
}
